package shuzu

func removeNthFromEnd(head *ListNode, n int) *ListNode {
	size := Size(head)
	dummy := &ListNode{Next: head}
	list := dummy
	for i := 0; i < size-n; i++ {
		list = list.Next
	}
	list.Next = list.Next.Next
	return dummy.Next
}
func Size(head *ListNode) int {
	ans := 0
	for head != nil {
		head = head.Next
		ans++
	}
	return ans
}
